<?php
/**
 * Created by PhpStorm.
 * User: Drunk
 * Date: 2017-3-2
 * Time: 3:25
 */

namespace dce;

class feedback{
    static $_log = [];

    public static function false($message, $code = null){
        return self::log($message, $code);
    }

    public static function true($message, $code = null){
        return self::log($message, $code, true);
    }

    public static function log($message, $code = null, $result = false){
        self::$_log = [
            'message' => $message,
            'code' => $code,
            'result' => $result,
        ];
        return $result;
    }

    public static function take(){
        $log = self::$_log;
        self::$_log = [];
        return empty($log) ? null : $log;
    }

    public static function info_false($message, $code = null){
        self::log($message, $code);
        return self::take();
    }

    public static function info_true($message, $code = null){
        self::log($message, $code, true);
        return self::take();
    }
}